package com.roncoo.student.stu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.roncoo.student.stu.entity.UserStudy;
import com.roncoo.student.stu.dao.UserStudyMapper;
import com.roncoo.student.stu.service.IUserStudyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jl
 * @since 2021-04-09
 */
@Service
public class UserStudyServiceImpl extends ServiceImpl<UserStudyMapper, UserStudy> implements IUserStudyService {
    @Resource
    private UserStudyMapper mapper;

    @Override
    public Page findAll(UserStudy study, Page page) {


        return mapper.selectAll(page,study);
    }

    /**
     * 将数据添加到学习记录表
     * @param userStudy
     */
    @Override
    public void addData(UserStudy userStudy) {
        Date date = new Date();
        //设置要获取到什么样的时间
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        //获取String类型的时间
        String createdate = sdf.format(date);
        userStudy.setGmtCreate(createdate);
        this.save(userStudy);
    }
}
